/*
 * @Descripttion: 
 * @version: 
 * @Author: wutao
 * @LastEditors: wutao
 * @LastEditTime: 2025-07-19 23:08:27
 */
import Vue from "vue";
import "@/styles/normalize.css";
import "@/styles/jgy.less";
import "@/components/blm/jgyCustComponent/index";
import App from "./App.vue";
import Vant from "vant";
import "vant/lib/index.css";
import eruda from "eruda";
import router from './router' 
Vue.use(Vant);
eruda.init();
window.Vue = Vue;
Vue.config.productionTip = false;
new Vue({
  router,
  render: (h) => h(App),
}).$mount("#app");

window.$.ajaxSetup({
  beforeSend: function (jqXHR, settings) {
    console.log("Ajax request intercepted:", settings.url);
    if (settings.url.indexOf(location.host + "/ai/h5/gateway") != -1) {
      console.log("has gateway");
      const pathName = location.pathname.replace(
        /\/commonpc|\/commonmobile/,
        ""
      ); //根路径根据客户环境替换
      settings.url = settings.url.replace(
        "/ai/h5/gateway",
        `${pathName}/ai/h5/gateway`
      );
      console.log("Ajax request intercepted: after ", settings.url);
    }
    //大模型排序接口单独处理
    if (
      window.currentSortTableDataExtra &&
      settings.url === "/gateway/render/getData"
    ) {
      const pathName = location.pathname.replace(
        /\/commonpc|\/commonmobile/,
        ""
      ); //根路径根据客户环境替换
      const oriData = JSON.parse(settings.data);
      oriData.source = "b_zhengquan_test20";
      if (oriData.condition === "") {
        oriData.model_sql = window.currentSortTableDataExtra.model_sql || "";
      }
      settings.data = JSON.stringify(oriData);
      settings.url = settings.url.replace(
        "/gateway/render/getData",
        `${pathName === "/" ? "" : pathName}/ai/h5/gateway/render/getData`
      );
    }
  },
});
